#!/usr/bin/python

import WykopRespDig
import WykopRespEntryComment

class WykopRespEntry:
    
    def _setData(self, Data):
        
        self.id = Data['id']
        self.author = Data['author']
        self.author_avatar = Data['author_avatar']	
        self.author_avatar_med	= Data['author_avatar_med']
        self.author_avatar_lo	= Data['author_avatar_lo']
        self.author_group	= Data['author_group']
        self.date	= Data['date']
        self.body	= Data['body']
        self.url	= Data['url']
        self.receiver	= Data['receiver']
        self.receiver_avatar	= Data['receiver_avatar']
        self.receiver_avatar_med = Data['receiver_avatar_med']	
        self.receiver_avatar_lo	= Data['receiver_avatar_lo']
        self.receiver_group	= Data['receiver_group']
        self.comments	= Data['comments']
        self.vote_count	= Data['vote_count']
        self.voters = Data['voters']
        try:
            self.embed	= Data['embed']
        except KeyError:
            self.embed =  WykopRespEntryComment.WykopRespEntryComment()
    
    def _normalizeData(self, Data):
    
        A = WykopRespDig.WykopRespDig()
        B = WykopRespEntryComment.WykopRespEntryComment()
        Obj = WykopRespEntry()
        Obj._setData(Data)
        Obj.voters = A._normalizeDatatoList(Obj.voters)
        Obj.comments = B._normalizeDatatoList(Obj.comments)
        return Obj
    
    def _normalizeDatatoList(self,Data):
        List = []
        for El in Data:
            A = WykopRespDig.WykopRespDig()
            B =WykopRespEntryComment.WykopRespEntryComment()
            Obj = WykopRespEntry()
            Obj._setData(El)
            Obj.voters = A._normalizeDatatoList(Obj.voters)
            Obj.comments = B._normalizeDatatoList(Obj.comments)
            List.append(Obj)
        return List